package com.ninghushangbao.ninghu.service.Impl;

import com.ninghushangbao.ninghu.controller.vo.UpdatePasswordVo;
import com.ninghushangbao.ninghu.mapper.UserMapper;
import com.ninghushangbao.ninghu.entity.User;
import com.ninghushangbao.ninghu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public User getUserById(int id) {
        return userMapper.getUserById(id);
    }

    @Override
    public User getUserByUserName(User user) {
        return userMapper.getUserByUserName(user);
    }

    @Override
    public List<User> getUsers() {
        List<User> users = userMapper.getUsers();
        return users;
    }

    @Override
    public List<User> getUserVo() {
        return userMapper.getUserVo();
    }

    @Override
    public void addUser(User user) {
        Date createTime = new Date();
        Date updateTime = new Date();
        user.setCreateTime(createTime);
        user.setUpdateTime(updateTime);
        userMapper.addUser(user);
    }

    @Override
    public void deleteUser(int id) {

    }

    @Override
    public void deleteUsersById(List<Integer> list) {
        userMapper.deleteUsersById(list);
    }

    @Override
    public void updateUser(User user) {
        user.setUpdateTime(new Date());
        userMapper.updateUser(user);
    }

    @Override
    public void updatePasswordById(User user) {
        userMapper.updatePasswordById(user);
    }

}
